package com.hzy.common.controller;

import com.hzy.common.vo.HomeConfigVO;
import com.hzy.pms.service.IProductCategoryService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.service.ISysConfigService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Copyright (C), 2018-2023
 * FileName: IndexController
 * Description: TODO
 * Author:   zengxin(zengxin@kbostar.com)
 * Date:     2023/10/31 11:30
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/no-auth/home")
public class IndexController {

//    private final ISysConfigService sysConfigService;
    private final IProductCategoryService categoryService;

    /**
     * 首页配置
     *
     * @return 首页配置
     */
    @GetMapping("/home-cfg")
    public R<HomeConfigVO> getHomeConfig() {
        HomeConfigVO res = new HomeConfigVO();
//        res.setBanners(sysConfigService.selectConfigByKey("h5.home.banner"));
        res.setCategoryList(categoryService.queryCategoryWithProductsForH5());
        return R.ok(res);
    }
    /**
     * 首页配置
     *
     * @return 首页配置
     */
    @GetMapping("/product-count")
    public ResponseEntity<HomeConfigVO> productCount() {
        HomeConfigVO res = new HomeConfigVO();
//        res.setBanners(sysConfigService.selectConfigByKey("h5.home.banner"));
        res.setCategoryList(categoryService.queryCategoryWithProductsForH5());
        return ResponseEntity.ok(res);
    }
}
